<!--
<!DOCTYPE html>
<head>
    <title>Registration</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content=""/>
    <script type="application/x-javascript"> addEventListener("load", function () {
        setTimeout(hideURLbar, 0);
    }, false);

    function hideURLbar() {
        window.scrollTo(0, 1);
    } </script>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link href="/css/style.css" rel='stylesheet' type='text/css'/>
    <link href="/css/style-responsive.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/css/font.css" type="text/css"/>
    <link href="/css/font-awesome.css" rel="stylesheet">
    <script src="/js/jquery2.0.3.min.js"></script>
    <style type="text/css">
        #bt{
            position: relative;
            left: 130px;
        }
    </style>
</head>
<body>
<div class="reg-w3">
    <div class="w3layouts-main">
        <h2>短信验证</h2>
        <form id="veryForm">
            <input type="text" class="ggg" name="empName" placeholder="请输入用户名" required="" id="empName"
                   style="width: 75%"/>
            <input type="text" class="ggg" name="empPhone" placeholder="请输入手机号" required="" id="empPhone"
                   style="width: 75%">&nbsp;&nbsp;<input id="btn"  type="button" class="btn btn-warning"
                                                          style="height:52px;background-color: #E9967A;width: 110px"  onclick="gettime(this);" value="获取验证码"/>
            <input type="text" class="ggg" name="verifyCode" placeholder="请输入验证码"  id="veryCode"
                   style="width: 75%"/><span id="span1"></span>

            <div class="clearfix"></div>
            <button type="button" class="btn btn-warning" id="bt" style="background-color: #E9967A;height: 50px;width: 130px">确认验证</button>
        </form>
    </div>
</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="/js/scripts.js"></script>
<script src="/js/jquery.slimscroll.js"></script>
<script src="/js/jquery.nicescroll.js"></script>
<script src="/js/jquery.scrollTo.js"></script>
</body>
</html>
<script type="text/javascript">
    var x=120;
    function gettime(obj) {
        if(x==0){
            obj.value="重新获取验证码";
            obj.removeAttribute("disabled");
            x=120;
            return;
        }else{
            obj.value="剩余"+x+"秒";
            obj.setAttribute("disabled",true);
            x&#45;&#45;;
        }
        setTimeout(function () { gettime(obj) },1000);
    }

        $("#btn").click(function () {
            /*if (!check().form()) {
                return;
            }*/
            $.ajax({
                type: "POST",
                url: "/emp/getInfo",
                dataType: "json",
                data: {
                    empName: $("#empName").val()
                },
                success: function (data) {
                    if (data.emp.euuId == null) {
                        //用户名不正确
                        alert("无此用户");
                    } else {
                        if (data.emp.empPhone != $("#empPhone").val()) {
                            //手机号不匹配
                            alert("手机号不匹配");
                        } else {
                            $.ajax({
                                type: "POST",
                                url: "/emp/getVeryCode",
                                dataType: "json",
                                data: {
                                    empPhone: $("#empPhone").val()
                                },
                                success: function (data) {
                                }
                            });
                        }
                    }

                }
            });
        });


       /*var check = function () {
            jQuery.validator.addMethod("regex", function (value, element, params) {
                var exp = new RegExp(params);
                return exp.test(value);
            }, "格式错误");
            return $("#veryForm").validate({
                rules: {
                    empName: {
                        required: true,
                    },
                    empPhone: {
                        required: true,
                        regex: "^[1][3,4,5,7,8,9][0-9]{9}$"
                    }
                },
                messages: {
                    empName: {
                        required: "",
                    },
                    empPhone: {
                        required: "",
                        regex: "手机号格式不正确"
                    }
                }
            });
        };*/

        $("#bt").click(function () {
           /* if (!check().form()) {
                return;
            }*/
            $.ajax({
                type: "POST",
                url: "/emp/verifyCode",
                dataType: "json",
                data: {
                    verifyCode: $("#veryCode").val()
                },
                success: function (data) {
                    if (data.info == "验证成功") {
                        window.location.href = "/updatePWD.html"
                    } else {
                        $("#span1").html("验证码不正确");
                    }
                }
            });
        });
</script>
-->
<!DOCTYPE html>
<head>
    <title>短信验证</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <!-- bootstrap-css -->
    <link rel="stylesheet" href="/css/bootstrap.min.css" >
    <!-- //bootstrap-css -->
    <!-- Custom CSS -->
    <link href="/css/style.css" rel='stylesheet' type='text/css' />
    <link href="/css/style-responsive.css" rel="stylesheet"/>
    <!-- font-awesome icons -->
    <link rel="stylesheet" href="/css/font.css" type="text/css"/>
    <link href="/css/font-awesome.css" rel="stylesheet">
    <!-- //font-awesome icons -->
    <script src="/js/jquery2.0.3.min.js"></script>
    <script src="/js/vue/vue.min.js"></script>
</head>
<style type="text/css">
    #sub{
        position: relative;
        right: 50px;
        bottom: 20px;
    }
</style>
<body>
<div class="log-w3">
    <div class="w3layouts-main">
        <h2>短信验证</h2>
        <form action="/emp/updatePassword" method="post">
            <!--<input type="text" class="ggg" name="empName" placeholder="请输入用户姓名" required="">
            <input type="password" class="ggg" name="empPassword" placeholder="请输入用户密码" required="">
            <input type="password" class="ggg" name="reEmpPassword" placeholder="请输入確認密码" required="">-->
            <!--<span><input type="checkbox" />记住密码</span>-->

            <input type="text" class="ggg" name="empName" placeholder="请输入用户名" required="" id="empName"
                   style="width: 75%"/>
            <input type="text" class="ggg" name="empPhone" placeholder="请输入手机号" required="" id="empPhone"
                   style="width: 75%" onmouseleave="checkInput()" oninput="changeBtnable()">&nbsp;&nbsp;<input id="btn"  disabled type="button" class="btn btn-warning"
                                                         style="height:52px;background-color: #E9967A;width: 110px; "  value="获取验证码" onclick="gettime(this);"/>
            <input type="text" class="ggg" name="verifyCode" placeholder="请输入验证码"  id="veryCode" required=""
                   style="width: 75%"/><!--<span id="span1"></span>-->
            <div class="clearfix"></div>
            <input type="submit" value="確認修改" name="login" id="sub" >
        </form>
    </div>
</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="/js/scripts.js"></script>
<script src="/js/jquery.slimscroll.js"></script>
<script src="/js/jquery.nicescroll.js"></script>
<script src="/js/jquery.scrollTo.js"></script>
</body>
</html>
<script>
    var empName,empPhone;

    function changeBtnable(){
        $("#btn").removeAttr("disabled");
    }
    function changeBtndisable(){
        $("#btn").attr("disabled","true");
    }
    function checkInput(){
        var text1= $("#empName").val();
        var text2=$("#empPhone").val();
        if(text1==null||text==""||text2==null||text2==""){
            changeBtndisable();
        }
        empName=text1;
        empPhone=text2;
    }


    var x=120;
    function gettime(obj){
        if(x==0){
            obj.value="点击重新获取";
            obj.removeAttribute("disabled");
            x=120;
            return;
        }else{
            obj.value="剩余 "+x+" 秒";
            obj.setAttribute("disabled",true);
            x--;
        }
        setTimeout(function () { gettime(obj) },1000);
    }

    $("#btn").click(function () {
        $.ajax({
            type: "POST",
            url: "/emp/getInfo",
            dataType: "json",
            data: {
                empName: $("#empName").val()
            },
            success: function (data) {
                if (data.emp.euuId == null) {
                    alert("无此用户");
                } else {
                    if (data.emp.empPhone != $("#empPhone").val()) {
                        alert("手机号不匹配");
                    } else {
                        $.ajax({
                            type: "POST",
                            url: "/emp/getVeryCode",
                            dataType: "json",
                            data: {
                                empPhone: $("#empPhone").val()
                            },
                            success: function (data) {
                            }
                        });
                    }
                }

            }
        });
    });

    $("#sub").click(function () {

        $.ajax({
            type: "POST",
            url: "/emp/verifyCode",
            dataType: "json",
            data: {
                verifyCode: $("#veryCode").val()
            },
            success: function (data) {
                if (data.info == "验证成功") {
                    window.location.href = "/updatePWD.html";
                } else {
                    alert(data.info);
                    window.location.href="/registration.html";

                }
            }
        });
    });
</script>


